#!/usr/bin/python
import MySQLdb


db = MySQLdb.connect(host="127.0.0.1", user="root", db="solar", port=3306)
cursor = db.cursor()
cursor.execute("""insert into solar_agg (time, watts) select now() time, avg(watts) watts from solar_data where time <= now()  and time > TIMESTAMPADD(MINUTE, -15, now())""")
cursor.close()
db.close()

